package app.action;

import java.awt.event.ActionEvent;
import java.io.File;

import javax.swing.JFileChooser;

import app.ui.AbsCommonPanel;
import app.ui.StartScr;

public class StartScrAct extends AbsCommonPanelAction {
	private StartScr startScr;
	private JFileChooser jFileChooser;
	private File file;

	public StartScrAct(AbsCommonPanel absCommonPanel) {
		super(absCommonPanel);
	}

	public void actionPerformed(ActionEvent e) {
		if (this.jFileChooser == null) {
			this.jFileChooser = new JFileChooser(startScr.getjTextField()
					.getText());
			jFileChooser.setFileFilter(startScr.getmFrame().getAppUtilities()
					.getFileUtilities());
			jFileChooser
					.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
		}

		int chooserVal = jFileChooser.showDialog(startScr, "This Folder");
		if (chooserVal == JFileChooser.APPROVE_OPTION) {
			file = jFileChooser.getSelectedFile();
			startScr.addressIsSet(file);
		}
	}

	@Override
	protected void doCatenation() {
		this.startScr = (StartScr) absCommonPanel;
	}

}
